﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.Data;

namespace WindowsFormsApplication2.CLASS
{
    class Borluulalt
    {
        #region " & PropertyS & "
        private string _Borluulaltd;
        public string BorluulaltId
        {
            get { return _Borluulaltd; }
            set { _Borluulaltd = value; }
        }
        private string _OrderId;
        public string OrderId
        {
            get { return _OrderId; }
            set { _OrderId = value; }
        }
        private string _XTolologchId;
        public string XTolologchId
        {
            get { return _XTolologchId; }
            set { _XTolologchId = value; }
        }
        private string _TolborId;
        public string TolborId
        {
            get { return _TolborId; }
            set { _TolborId = value; }
        }
        private string _WorkerId;
        public string WorkerId
        {
            get { return _WorkerId; }
            set { _WorkerId = value; }
        }
        private string _XTolologchPass;
        public string XTolologchPass
        {
            get { return _XTolologchPass; }
            set { _XTolologchPass = value; }
        }
        #endregion
        public Borluulalt()
        {
            //butsets

        }
        public Borluulalt(string _XTolologchId, string _XTolologchName, string _XTolologchUName, string _XTolologchAddress, string _XTolologchPhone, string _XTolologchPass)
        {
            this.BorluulaltId = _XTolologchId;
            this.OrderId = _XTolologchName;
            this.XTolologchId = _XTolologchUName;
            this.TolborId = _XTolologchAddress;
            this.WorkerId = _XTolologchPhone;
            this.XTolologchPass = _XTolologchPass;
        }
        
        public static bool AddFunction(string _BorluulaltId, string _OrderId, string _XTolologchId, string _TolborId, string _WorkerId)
        {

           // DBTools._Conn.Open();
            DBTools._Comm.CommandText = "StoredProcedureBorluulalt";
            DBTools._Comm.CommandType = CommandType.StoredProcedure;
            DBTools._Comm.Parameters.Add(new SqlParameter("@BorluulaltId", SqlDbType.NVarChar, 8)).Value = _BorluulaltId;
            DBTools._Comm.Parameters.Add(new SqlParameter("@OrderId", SqlDbType.NVarChar, 8)).Value = _OrderId;
            DBTools._Comm.Parameters.Add(new SqlParameter("@XTolologchId", SqlDbType.NVarChar, 8)).Value = _XTolologchId;
            DBTools._Comm.Parameters.Add(new SqlParameter("@TolborId", SqlDbType.NVarChar, 10)).Value = _TolborId;
            DBTools._Comm.Parameters.Add(new SqlParameter("@WorkerId", SqlDbType.NVarChar, 8)).Value = _WorkerId;


            DBTools._Comm.Parameters.Add(new SqlParameter("@Otype", SqlDbType.NVarChar, 4)).Value = "ADD";
            SqlParameter prm = new SqlParameter("@returnvalue", SqlDbType.TinyInt);
            DBTools._Comm.Parameters.Add(prm);
            prm.Direction = ParameterDirection.Output;
            string isOk;
            try
            {
                int rowcount = DBTools._Comm.ExecuteNonQuery();
                DBTools._Comm.Parameters.Clear();
                isOk = Convert.ToString(prm.Value);



                if (isOk == "1")
                {
                    return true;

                }
                else
                {
                    return false;

                }
            }


            catch (SqlException ex)
            {
                DBTools._Comm.Parameters.Clear();
                MessageBox.Show(ex.Message);


            }

            return false;
        }
    }
}
